<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>

	<head>
		<meta content="text/html; charset=UTF-8" />
		<title>流程列表</title>
		<link href="../common/css/global.css" />
		<link rel="stylesheet" type="text/css" href="../plugins/layui/css/layui.css" />
		<link href="../plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
		<link rel="stylesheet" href="../plugins/bootstrap-table/bootstrap-table.css" />
		<!--	<link rel="stylesheet" href="../plugins/layui/css/modules/layer/default/layer.css" />-->
	</head>

	<body>
		<div class="container">
			<button onclick="openlay()" class="layui-btn layui-btn-primary layui-btn-sm layui-btn-radius">打开</button>
			<div>
				<table id="table" width="100%"></table>
			</div>

		</div>
		<script src="../common/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../plugins/bootstrap/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../plugins/bootstrap-table/bootstrap-table.min.js" type="text/javascript" charset="UTF-8"></script>

		<script src="../plugins/bootstrap-table/locale/bootstrap-table-zh-CN.js" type="text/javascript" charset="UTF-8"></script>
	</body>
	<script type="text/javascript" charset="UTF-8">
		function openlay() {
			parent.layer.open({
				//				title: false,
				maxmin: true,
				type: 2,
				area: ['600px','600px'],
				content: './views/form/bill2.html', //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
//				btn: ['按钮一', '按钮二', '按钮三'],
//				yes: function(index, layero) {
//					//按钮【按钮一】的回调
//					alert(index);
//					console.log(layero);
//				},
//				btn2: function(index, layero) {
//					//按钮【按钮二】的回调
//					alert(index);
//					console.log(layero);
//					//return false 开启该代码可禁止点击该按钮关闭
//				},
//				btn3: function(index, layero) {
//					//按钮【按钮三】的回调
//					alert(index);
//					console.log(layero);
//					layer.anim(index);
//					return false;
//					//return false 开启该代码可禁止点击该按钮关闭
//				},
				anim: 6
			});
		}
		$(document).ready(function() {
			var col = [{
					checkbox: true
				},
				{
					title: '流程定义名称',
					field: 'name',
					align: 'center',
					valign: 'middle'
				},
				{
					title: '流程定义key',
					field: 'key',
					align: 'center',
					valign: 'middle'
				},
				{
					title: '版本',
					field: 'version',
					align: 'center',
					valign: 'middle'
				},
				{
					title: '部署ID',
					field: 'deploymentId',
					align: 'center',
					valign: 'middle'
				},
				{
					title: '操作',
					formatter: function(value, row, index) {
						return '<button class="layui-btn layui-btn-primary layui-btn-sm layui-btn-radius" onclick=\'start("/actres/start"' + row.key + '")\'>&nbsp;&nbsp;启动流程&nbsp;&nbsp;</button>&nbsp;&nbsp;&nbsp;' +
							'<button class="layui-btn layui-btn-sm layui-btn-radius layui-btn-danger" onclick="del(\'' + row.deploymentId + '\')">&nbsp;&nbsp;删除&nbsp;&nbsp;</button>';
						//							+'<button class="layui-btn layui-btn-sm layui-btn-radius>打开layer</button>';
					},
					align: 'center',
					valign: 'middle',
					visible: true
				}
			];
			$('#table').bootstrapTable({
				locale: 'zh-CN',
				sidePagination: "client",
				striped: true,
				undefinedText: "",
				pagination: false,
				singleSelect: false,
				pageSize: 30,
				cache: false,
				pageNumber: 1,
				pageList: [30, 50, 100],
				search: true,
				uniqueId: "id",
				showColumns: false,
				showRefresh: true,
				undefinedText: '',
				columns: col,
				url:baseUrl+ '/actres',
				queryParams: function(params) {
					return {}
				},
				type: "get",
			});

		});
		var start = function(key) {
			$.get(baseUrl+"/actres/start?processDefinitionKey=" + key, function(data) {
				alert(data);
			});
		}

		function del(id) {
			console.log(id);
			$.ajax({
				type: "delete",
				url: baseUrl+"/actres?processDefinitionId=" + id,
				async: true,
				data: {
					'processDefinitionId': id
				},
				success: function(data) {
					window.location.reload();
				}
			});
		}
	</script>

</html>